from graphviz import Digraph

def create_tree_graph():
    dot = Digraph()

    # 设置全局属性
    dot.graph_attr.update(rankdir='LR', bgcolor='white', fontsize='14', fontname='SimHei')

    # 添加主要节点
    dot.node('S', 'openapi', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('A', '服务集成', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('B', '企业级API网关', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('C', 'API自动化测试平台', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('D', 'API可视化编排平台', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('E', 'API低代码开发平台', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('F', 'API管理中心', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('G', 'API注册', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('H', '服务审核', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('I', '数据源管理', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('J', 'API监控中心', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('K', '组织权限中心', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('L', '技术可行性', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('M', '数据安全性', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('N', '实时性', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('O', '可扩展性', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')
    dot.node('Z', '111111', shape='rectangle', style='filled', fillcolor='#f0f0ff', fontcolor='black')

    # 连接节点
    dot.edges(['SA', 'SB', 'SC', 'SD', 'SE', 'SF', 'SG', 'SH', 'SI', 'SJ', 'SK'])
    dot.edge('F', 'Z', label='API管理')
    dot.edge('L', 'FA')
    dot.edge('M', 'FB')
    dot.edge('N', 'FC')

    return dot


if __name__ == '__main__':
    dot = create_tree_graph()
    dot.render("api_tree", view=True)